package com.yingu.bookmanage_ssm1.Controller;

import java.util.Map;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.yingu.bookmanage_ssm1.Pojo.UserPojo;
import com.yingu.bookmanage_ssm1.Services.UserServiceImpl;

@Controller
@RequestMapping(value="/user")
public class UserController {
	
	@Autowired
	UserServiceImpl usi;
	
	
	@RequestMapping(value="login")
	public String login(UserPojo up,Map<String,Object> map,HttpSession session){
		UserPojo user = usi.login(up);
		
		if(user!=null){
			session.setAttribute("user", user);
			map.put("flag",1);
			return "login";
			
		}else{
			map.put("flag",2);
			return "book/findAll";
		}
	}
}
